
public class Pixel {
		
		public int R;
		public int G;
		public int B;
		public int a;
	
		public Pixel(int r, int g, int b, int a){
			this.R=r;
			this.G=g;
			this.B=b;
			this.a=a;
		}
		
		public Pixel(int rgba){
			this.a = (rgba >> 24) & 0xFF;
			this.R = (rgba >> 16) & 0xFF;
			this.G = (rgba >> 8) & 0xFF;
			this.B =  rgba & 0xFF;
		}
		
		public Pixel(Pixel p)
		{
			this.a = p.a;
			this.R = p.R;
			this.G = p.G;
			this.B = p.G;
			
		}
		
		public void absSub(Pixel p){
			this.a = this.a - p.a;
			this.R = this.R - p.R;
			this.G = this.G - p.G;
			this.B = this.B - p.B;
			
			if(a<0) { a=-a; }
			if(R<0) { R=-R; }
			if(G<0) { G=-G; }
			if(B<0) { B=-B; }
		}
		
		public void absAdd(Pixel p){
			this.a = this.a + p.a;
			this.R = this.R + p.R;
			this.G = this.G + p.G;
			this.B = this.B + p.B;
			if(a<0) { a=-a; }
			if(R<0) { R=-R; }
			if(G<0) { G=-G; }
			if(B<0) { B=-B; }
		}
		
		public Pixel add(Pixel p){
			this.a = this.a + p.a;
			this.R = this.R + p.R;
			this.G = this.G + p.G;
			this.B = this.B + p.B;
			return this;
		}
		
		public void normalize(){
			if(this.a > 255){ this.a=255; }
			if(this.R > 255){ this.R=255; }
			if(this.G > 255){ this.G=255; }
			if(this.B > 255){ this.B=255; }
			
			if(this.a < 0){ this.a=0; }
			if(this.R < 0){ this.R=0; }
			if(this.G < 0){ this.G=0; }
			if(this.B < 0){ this.B=0; }
		
		}
}
